package com.cml.topicsystem.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author cml
 * @create 2021/6/2 13:25
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private String code;
    private String message;
    private Object data;

    public R(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static R ok(){
        R r = new R("20000","操作成功");
        return r;
    }

    public static R error(){
        R r = new R("40000","操作失败");
        return r;
    }

    public R code(String code){
        this.setCode(code);
        return this;
    }

    public R date(Object data){
        this.setData(data);
        return this;
    }

    public R message(String message){
        this.setMessage(message);
        return this;
    }
}
